/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("zm_message",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using VOL.AppManager.IServices;
using VOL.Core.Enums;
using VOL.Core.Filters;
using VOL.Core.ManageUser;
using VOL.Core.Middleware;
using VOL.Entity.新文件夹;

namespace VOL.AppManager.Controllers
{
    public partial class zm_messageController
    {
        private readonly Izm_messageService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public zm_messageController(
            Izm_messageService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }

        [ActionLog("查询")]
        [ApiActionPermission("zm_message", ActionPermissionOptions.Search)]
        [HttpPost, Route("GetData")]
        public ActionResult GetData([FromBody] zmmessageQuery param)
        {
            if (UserContext.Current.RoleId == 132 || UserContext.Current.RoleId == 133 || UserContext.Current.RoleId == 126 || UserContext.Current.RoleId == 137)
            {
                param.xzqdm = UserContext.Current.XzqDm;
                param.citydm = UserContext.Current.CityDm;
                param.provcode = UserContext.Current.ProvCode;

            }
            return JsonNormal(InvokeService("GetData", new object[] { param }));
        }
        [ActionLog("已读")]
        [ApiActionPermission("zm_message", ActionPermissionOptions.Search)]
        [HttpPost, Route("updateIsRead")]
        public ActionResult updateIsRead([FromBody] zmmessageQuery param)
        {
            if (UserContext.Current.RoleId == 132 || UserContext.Current.RoleId == 133 || UserContext.Current.RoleId == 126 || UserContext.Current.RoleId == 137)
            {
                param.xzqdm = UserContext.Current.XzqDm;
                param.citydm = UserContext.Current.CityDm;
                param.provcode = UserContext.Current.ProvCode;

            }
            return JsonNormal(InvokeService("updateIsRead", new object[] { param }));
        }

        private object InvokeService(string methodName, object[] parameters)
        {
            return Service.GetType().GetMethod(methodName).Invoke(Service, parameters);
        }
    }
}
